<?php

/**
 * 转成小驼峰 如：third_party => thirdParty  third/party => thirdParty
 *
 * 2024.04.18 cighsen02 3651872575
 */
function camel_case($thing = '')
{
    if (empty($thing)) return $thing;

    // 首先，替换开头的字母为小写
    $thing = preg_replace_callback('#^[a-z]#', function($piece) {
        return strtolower($piece[0]);
    }, $thing);

    // 然后，替换下划线后面的字母为大写
    $thing = preg_replace_callback('#_([a-z])#', function($piece) {
        return strtoupper($piece[1]);
    }, $thing);

    return $thing;
}
